package com.chao.yyks.modular.sys.controller;

import com.alibaba.fastjson.JSONObject;
import com.chao.common.util.log.Inter;
import com.chao.common.util.reaction.PageList;
import com.chao.yyks.modular.sys.bean.EnStudent;
import com.chao.yyks.modular.sys.service.EnStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;


/**
 * 学生Controller
 * chao
 * 2024-09-09
 */
@RestController
@RequestMapping("/enStudent")
public class EnStudentController {

	/**
	 * 学生Service
	 */
	@Autowired
	private EnStudentService enStudentService;

	/**
	 * 新增学生
	 */
	@Inter("EST_ADD_01")
	@RequestMapping(method = RequestMethod.POST, value = "insertEnStudent")
	public void insertEnStudent(@RequestBody EnStudent enStudent){
		enStudentService.insertEnStudent(enStudent);
	}

	/**
	 * 导入学生
	 */
	@Inter("EST_ADD_02")
	@RequestMapping(method = RequestMethod.POST, value = "importEnStudent")
	public JSONObject importEnStudent(@RequestParam("file") MultipartFile file){
		return enStudentService.importEnStudent(file);
	}

//	/**
//	 * 导入学生
//	 */
//	@Inter("EST_ADD_02")
//	@RequestMapping(method = RequestMethod.GET, value = "importEnStudent")
//	public JSONObject importEnStudent(){
//		return enStudentService.importEnStudent(null);
//	}

	/**
	 * 修改学生
	 */
	@Inter("EST_EDT_01")
	@RequestMapping(method = RequestMethod.POST, value = "updateEnStudent")
	public void updateEnStudent(@RequestBody EnStudent enStudent){
		enStudentService.updateEnStudent(enStudent);
	}

	/**
	 * 修改密码
	 */
	@Inter("EST_EDT_02")
	@RequestMapping(method = RequestMethod.POST, value = "updatePassword")
	public void updatePassword(@RequestBody JSONObject json){
		enStudentService.updatePassword(json);
	}

	/**
	 * 重置密码
	 */
	@Inter("EST_EDT_03")
	@RequestMapping(method = RequestMethod.POST, value = "resetPassword")
	public void resetPassword(@RequestBody EnStudent enStudent){
		enStudentService.resetPassword(enStudent.getStudentId());
	}

	/**
	 * 删除学生
	 */
	@Inter("EST_DEL_01")
	@RequestMapping(method = RequestMethod.POST, value = "deleteEnStudent")
	public void deleteEnStudent(@RequestBody EnStudent enStudent){
		enStudentService.deleteEnStudent(enStudent.getStudentId());
	}

	/**
	 * 查询学生详情
	 */
	@Inter("EST_SEL_01")
	@RequestMapping(method = RequestMethod.GET, value = "selectEnStudentByStudentId")
	public EnStudent selectEnStudentByStudentId(String studentId){
		return enStudentService.selectEnStudentByStudentId(studentId);
	}

	/**
	 * 查询学生列表
	 */
	@Inter("EST_SEL_02")
	@RequestMapping(method = RequestMethod.GET, value = "selectEnStudentByList")
	public PageList<EnStudent> selectEnStudentByList(@RequestParam Map<String,Object> map){
		return enStudentService.selectEnStudentByList(new JSONObject(map));
	}

	/**
	 * 分页查询学生列表
	 */
	@Inter("EST_SEL_03")
	@RequestMapping(method = RequestMethod.GET, value = "selectEnStudentByPage")
	public PageList<EnStudent> selectEnStudentByPage(@RequestParam Map<String,Object> map){
		return enStudentService.selectEnStudentByPage(new JSONObject(map));
	}


}